/*
 * =====================================================================================
 *
 *       Filename:  rwlock.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  02/25/2011 02:47:39 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  dp (8023), dp8023@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#include "rwlock.h"

bool rwlock::init()
{
	if (pthread_rwlock_init(&m_rwlock, NULL) == 0)
		return true;

	return false;
}

bool rwlock::destroy()
{
	if (pthread_rwlock_destroy(&m_rwlock) == 0)
		return true;

	return false;
}

bool rwlock::rdlock()
{
	if (pthread_rwlock_rdlock(&m_rwlock) == 0)
		return true;

	return false;
}

bool rwlock::wrlock()
{
	if (pthread_rwlock_wrlock(&m_rwlock) == 0)
		return true;

	return false;
}

bool rwlock::unlock()
{
	if (pthread_rwlock_unlock(&m_rwlock) != 0)
		return true;

	return false;
}

